<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>箭头函数学习</title>
    <style>
        div {
            width: 200px;
            height: 200px;
            background: #58a;
        }
    </style>
</head>

<body>
    <div id="ad">

    </div>

    <script>
        let ad = document.getElementById('ad');
        console.log(this)
            // ad.addEventListener('click', function() {
            //         //把外层函数作用域下的this进行保存
            //         let _this = this
            //         console.log(this)
            //         setTimeout(function() {
            //             console.log(_this);
            //             _this.style.background = 'pink';
            //         }, 2000);
            //     })
            //     // console.log(this);

        ad.addEventListener('click', function() {
            console.log(this);
            setTimeout(() => {
                console.log(this);
                this.style.background = 'pink';
            }, 1000);
        })

        const arr = [1, 2, 3, 5, 7, 8, 10];
        // const result = arr.filter(function(item) {
        //     if (item % 2 === 0) {
        //         return true
        //     } else {
        //         return false
        //     }
        // });

        const result = arr.filter(item => item % 2 === 0);
        console.log(result);
    </script>
</body>

</html>